package xddq

import (
	"fmt"
	D "websocket_apn/define"
	"websocket_apn/log"
	"websocket_apn/proto"
)

var SkyTradeAddMap = map[int]D.SkyTradeAddInfo{
	10000: {Name: "未知地点", Specialty: 1000},
	10001: {Name: "北寒界", Specialty: 1003},
	10002: {Name: "石林", Specialty: 1002},
	10003: {Name: "雾隐谷", Specialty: 1001},
	10004: {Name: "紫霄仙宫", Specialty: 1009},
	10005: {Name: "青莲台", Specialty: 1005},
	10006: {Name: "瑶池仙岛", Specialty: 1015},
	10007: {Name: "天机阁", Specialty: 1008},
	10008: {Name: "离火境", Specialty: 1012},
	10009: {Name: "悟道楼", Specialty: 1004},
	10010: {Name: "文津阁", Specialty: 1010},
	10011: {Name: "天剑峰", Specialty: 1014},
	10012: {Name: "破虚门", Specialty: 1013},
	10013: {Name: "仙竹林", Specialty: 1006},
	10014: {Name: "昆仑秘境", Specialty: 1011},
	10015: {Name: "青冥宫", Specialty: 10037},
}

var SkyTradeGoodsMap = map[int]D.SkyTradeGoodsInfo{
	1000: {ID: "E807", Name: "未知货物", Price: 100},
	1001: {ID: "E907", Name: "苍云仙芝", Price: 100},
	1002: {ID: "EA07", Name: "灵壁石", Price: 100},
	1003: {ID: "EB07", Name: "寒烟鹿茸", Price: 200},
	1004: {ID: "EC07", Name: "菩提子", Price: 200},
	1005: {ID: "ED07", Name: "五彩玄莲", Price: 300},
	1006: {ID: "EE07", Name: "天青竹", Price: 300},
	1007: {ID: "EF07", Name: "九幽玉", Price: 400},
	1008: {ID: "F007", Name: "永夜明珠", Price: 400},
	1009: {ID: "F107", Name: "仙蚕丝绸", Price: 500},
	1010: {ID: "F207", Name: "慧心果", Price: 500},
	1011: {ID: "F307", Name: "七须灵参", Price: 600},
	1012: {ID: "F407", Name: "火凤羽", Price: 600},
	1013: {ID: "F507", Name: "太虚星草", Price: 700},
	1014: {ID: "F607", Name: "赤玄铁", Price: 700},
	1015: {ID: "F707", Name: "九曲仙酿", Price: 800},
}

//
func (xd *XdDriver) CheckPersonInfoData(allInfo D.DemonLeagueAllInfo) {
	//上报地点  紫霄仙宫
	xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_SKY_TRADE_REPORT_GOODS, fmt.Sprintf("08 %s", D.ActivityList[D.Activity_Immortal_Domain_Business_Journey])))
	//获取仙商录
	xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_SKY_TRADE_LOG, fmt.Sprintf("08 %s", D.ActivityList[D.Activity_Immortal_Domain_Business_Journey])))
	//购买瑶池仙岛  九曲仙酿 20
	xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_SKY_TRADE_BUY, fmt.Sprintf("08 %s 10 96 4E 18 F7 07 20 14 28 01", D.ActivityList[D.Activity_Immortal_Domain_Business_Journey])))
	/*
		[DEBUG] [2024/06/23 16:02:12] [PRJ/websocket_apn/main_test.go]:[  195]:   ↓↓↓↓↓ game cmd[15005]-unkown - len:47
		[DEBUG] [2024/06/23 16:02:12] [PRJ/websocket_apn/main_test.go]:[  197]:   PayloadBytes: 71 AB 00 00 00 2F 00 00 3A 9D 00 00 02D4 07 01 81 E2 08 00 12 08 08 F7 07 10 14 18 B0 6D 12 08 08 ED 07 10 01 18 86 02 18 B9 02 20 28 28 02
		[DEBUG] [2024/06/23 16:02:12] [PRJ/websocket_apn/main_test.go]:[  199]:   	>>> 1 - code 08[8] len:0-_
		[DEBUG] [2024/06/23 16:02:12] [PRJ/websocket_apn/main_test.go]:[  199]:   	>>> 2 - code 12[18] len:8-08 F7 07 10 14 18 B0 6D_
		��m
		[DEBUG] [2024/06/23 16:02:12] [PRJ/websocket_apn/main_test.go]:[  199]:   	>>> 3 - code 12[18] len:8-08 ED 07 10 01 18 86 02_
		��
	*/
	//前往文津阁
	xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_SKY_TRADE_MOVE, fmt.Sprintf("08 %s 10 9A 4E", D.ActivityList[D.Activity_Immortal_Domain_Business_Journey])))
	//使用48个加速
	xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_SKY_TRADE_SPEED_UP, fmt.Sprintf("08 %s 10 30", D.ActivityList[D.Activity_Immortal_Domain_Business_Journey])))
	//查询
	xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_SKY_TRADE_RED, fmt.Sprintf("08 %s", D.ActivityList[D.Activity_Immortal_Domain_Business_Journey])))
	/*[DEBUG] [2024/06/23 16:08:48] [PRJ/websocket_apn/main_test.go]:[  193]:   ↑↑↑↑↑ game cmd[215026]-unkown - len:23
	  [DEBUG] [2024/06/23 16:08:48] [PRJ/websocket_apn/main_test.go]:[  197]:   PayloadBytes: 71 AB 00 00 00 17 00 03 47 F2 00 00 02D4 07 01 81 E2 08 95 CF D3 04
	  [DEBUG] [2024/06/23 16:08:48] [PRJ/websocket_apn/main_test.go]:[  195]:   ↓↓↓↓↓ game cmd[15026]-unkown - len:36
	  [DEBUG] [2024/06/23 16:08:48] [PRJ/websocket_apn/main_test.go]:[  197]:   PayloadBytes: 71 AB 00 00 00 24 00 00 3A B2 00 00 02D4 07 01 81 E2 08 00 12 0E 30 30 30 31 30 30 30 30 30 31 30 30 30 30
	  [DEBUG] [2024/06/23 16:08:48] [PRJ/websocket_apn/main_test.go]:[  199]:   	>>> 1 - code 08[8] len:0-_
	  [DEBUG] [2024/06/23 16:08:48] [PRJ/websocket_apn/main_test.go]:[  199]:   	>>> 2 - code 12[18] len:14-30 30 3031 30 30 30 30 30 31 30 30 30 30_
	  00010000010000
	*/
	//全部卖出 九曲鲜酿 20
	xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_SKY_TRADE_BUY, fmt.Sprintf("08 %s 10 9A 4E 18 F7 07 20 14 28 02", D.ActivityList[D.Activity_Immortal_Domain_Business_Journey])))
	//购买文津阁  慧心果 20
	xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_SKY_TRADE_BUY, fmt.Sprintf("08 %s 10 9A 4E 18 F2 07 20 29 28 01", D.ActivityList[D.Activity_Immortal_Domain_Business_Journey])))
	//前往昆仑秘境
	xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_SKY_TRADE_MOVE, fmt.Sprintf("08 %s 10 9E 4E", D.ActivityList[D.Activity_Immortal_Domain_Business_Journey])))
	//挑战妖盟
	xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_SKY_TRADE_CHALLENGE_INFO, fmt.Sprintf("08 %s 10 %s", D.ActivityList[D.Activity_Immortal_Domain_Business_Journey], "FE 9A A5 EC 73")))

}

//查看仙域商图信息结果
func (xd *XdDriver) CheckSkyTradeInfoData(info D.SkyTradeInfo) {
	for _, add := range info.Add {
		if addInfo, ok := SkyTradeAddMap[add.IDi]; ok {
			addInfo.Lack = add.Lack
			if addInfo.Lack < 1001 || addInfo.Lack > 1015 {
				addInfo.Lack = 1000
			}
			for i := 0; i < 15; i++ {
				add.Goods[i].Name = SkyTradeGoodsMap[add.Goods[i].IDi].Name
				add.Goods[i].Price = SkyTradeGoodsMap[add.Goods[i].IDi].Price
			}
			addInfo.Goods = add.Goods
			addInfo.Name = SkyTradeAddMap[add.IDi].Name
			addInfo.Specialty = SkyTradeAddMap[add.IDi].Specialty
			SkyTradeAddMap[add.IDi] = addInfo
			log.Infof("仙域商途-[%s] 特产(%s) 紧缺(%s) ", addInfo.Name, SkyTradeGoodsMap[addInfo.Specialty].Name, SkyTradeGoodsMap[addInfo.Lack].Name, addInfo)
		}
	}
}
